class Notification extends DateTracker implements Comparable {

    static belongsTo = Company

    OfficeCallType type
    Representative rep
    Person contact
    Company company
    boolean complete = false
    Date date
    String reason
    String result
    String notes

    static constraints = {
        type(nullable:true)
        rep(nullable:false)
        contact(nullable:true)
        company(nullable:false)
        date(nullale:false)
        reason(nullable:true, blank:false, maxSize:2048)
        result(nullable:true, blank:true, maxSize:2048)
        notes(nullable:true, maxSize:2048)
    }

    int compareTo(obj) {
        if (date.equals(obj.date)) {
            if (complete == obj.complete) {
                return 1
            } else {
                return obj.complete.compareTo(complete)
            }
        }
        obj.date.compareTo(date)
    }

    String toString() {
        new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm").format(date)
    }
}
